Install a Xpenology NAS on KVM with Its Own IP Address

Our lab ended up with four spare mechanical drives, and I asked my boss to buy a NAS enclosure for them. I made a mistake and bought a DAS instead: it has USB, but no Ethernet port or operating system. It is essentially a large external drive. Fortunately, its 5 Gbps USB 3.0 connection is enough for four drives in RAID 0, so I decided to build a virtual NAS around it.

The virtualized Xpenology system needed its own IP address on the network, so I looked at running it in a virtual machine.

I considered three VM approaches:

  1. KVM + block device passthrough + virtio-scsi
  2. VMware + disk passthrough
  3. Hyper-V + disk passthrough

I chose the first approach for this build. In my assessment, VMware had too much performance overhead, while the Hyper-V option required an expansion card. My enclosure is just a USB drive and I do not have that card.

Install KVM and configure bridging

1
2
sudo apt update
sudo apt install qemu-kvm bridge-utils

On my Ubuntu 22.04 installation, NetworkManager manages networking instead of netplan. That makes many online bridge tutorials inapplicable, so I configured the bridge with nmcli. First, find the active connection:

1
2
3
4
nmcli connection show --active

NAME UUID TYPE DEVICE
Wired connection 1 aee52681-2068-3bfb-8536-16b3f4581145 ethernet enp39s0

Write down the physical interface name. Mine is enp39s0. Next, create a bridge named br0 and configure it for DHCP:

1
2
sudo nmcli connection add type bridge con-name br0 ifname br0
sudo nmcli connection modify br0 ipv4.method auto

I recommend DHCP. If you have a reason to use a static address, configure the bridge like this instead:

1
2
3
4
sudo nmcli connection modify br0 ipv4.method manual \
ipv4.addresses 192.168.1.100/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns "8.8.8.8,1.1.1.1"

The next steps can disconnect the machine from the network. Take care if you can only access it remotely.

Remove the old physical connection and attach the interface to the new bridge:

1
2
3
4
5
6
7
8
9
10
11
# 删除旧的物理网卡连接配置(将 "Wired connection 1" 替换为你的连接名),执行这一步会断网
sudo nmcli connection delete "Wired connection 1"

# 将物理网卡 enp39s0 作为从设备添加到 br0
sudo nmcli connection add type bridge-slave con-name br0-port-enp39s0 ifname enp39s0 master br0

# 关闭STP,至少在我的网络里面开了就获取不到IP地址
sudo nmcli connection modify br0 bridge.stp no

# 激活此网口
sudo nmcli connection up br0

The bridge has a different MAC address from the original interface, so the assigned IP may change. Reconnect using the new address.

Install Xpenology in KVM

The QEMU command line is long and I did not want to keep editing it, so I used libvirt and its graphical manager for the KVM guest:

1
2
3
sudo apt install virt-manager libvirt-daemon-system libvirt-clients bridge-utils -y
sudo systemctl enable --now libvirtd
sudo usermod -aG libvirt $(whoami)

When installation finishes, launch virt-manager from the command line.

For the boot image, download rr, an open-source one-click Xpenology installer:

1
wget https://github.com/RROrg/rr/releases/download/25.6.5/rr-25.6.5.img.zip

I recommend checking for a newer release, which may have fewer bugs than the version in this example.

Extract the downloaded archive. The resulting image is the guest’s boot disk:

  1. In the QEMU settings, create a new virtual machine.

  2. Create a normal 25 GB virtual disk for the operating system.

  3. image-20250701152702440

  4. Attach the extracted img as a USB device, then select it under Boot Options.

    image-20250701152652389

  5. Start RR and choose a NAS model. I chose the DS918+.

  6. After RR finishes compiling and installing, boot the VM and map the physical disk into it. My disk is /dev/sda. Then start the installation:

    image-20250701153651202

Here is the finished system:

image-20250701153718274

That completes the build.